package com.training.web.controller.comtent;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.training.common.annotation.Log;
import com.training.common.core.controller.BaseController;
import com.training.common.core.domain.AjaxResult;
import com.training.common.enums.BusinessType;
import com.training.content.domain.AssessInfo;
import com.training.content.service.IAssessInfoService;
import com.training.common.utils.poi.ExcelUtil;
import com.training.common.core.page.TableDataInfo;

/**
 * 考核信息Controller
 * 
 * @author training
 * @date 2021-10-25
 */
@RestController
@RequestMapping("/assess/info")
public class AssessInfoController extends BaseController
{
    @Autowired
    private IAssessInfoService assessInfoService;

    /**
     * 查询考核信息列表
     */
    @PreAuthorize("@ss.hasPermi('assess:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssessInfo assessInfo)
    {
        startPage();
        List<AssessInfo> list = assessInfoService.selectAssessInfoList(assessInfo);
        return getDataTable(list);
    }

    /**
     * 导出考核信息列表
     */
    @PreAuthorize("@ss.hasPermi('assess:info:export')")
    @Log(title = "考核信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AssessInfo assessInfo)
    {
        List<AssessInfo> list = assessInfoService.selectAssessInfoList(assessInfo);
        ExcelUtil<AssessInfo> util = new ExcelUtil<AssessInfo>(AssessInfo.class);
        return util.exportExcel(list, "考核信息数据");
    }

    /**
     * 获取考核信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('assess:info:query')")
    @GetMapping(value = "/{assessId}")
    public AjaxResult getInfo(@PathVariable("assessId") Long assessId)
    {
        return AjaxResult.success(assessInfoService.selectAssessInfoByAssessId(assessId));
    }

    /**
     * 新增考核信息
     */
    @PreAuthorize("@ss.hasPermi('assess:info:add')")
    @Log(title = "考核信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssessInfo assessInfo)
    {
        return toAjax(assessInfoService.insertAssessInfo(assessInfo));
    }

    /**
     * 修改考核信息
     */
    @PreAuthorize("@ss.hasPermi('assess:info:edit')")
    @Log(title = "考核信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssessInfo assessInfo)
    {
        return toAjax(assessInfoService.updateAssessInfo(assessInfo));
    }

    /**
     * 删除考核信息
     */
    @PreAuthorize("@ss.hasPermi('assess:info:remove')")
    @Log(title = "考核信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assessIds}")
    public AjaxResult remove(@PathVariable Long[] assessIds)
    {
        return toAjax(assessInfoService.deleteAssessInfoByAssessIds(assessIds));
    }
}
